package com.binest.myNolikes.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.binest.common.annotation.Log;
import com.binest.common.core.controller.BaseController;
import com.binest.common.core.domain.AjaxResult;
import com.binest.common.enums.BusinessType;
import com.binest.myNolikes.domain.MyNolikes;
import com.binest.myNolikes.service.IMyNolikesService;
import com.binest.common.utils.poi.ExcelUtil;
import com.binest.common.core.page.TableDataInfo;

/**
 * 我的不喜欢Controller
 * 
 * @author wwd
 * @date 2024-01-31
 */
@RestController
@RequestMapping("/myNolikes")
public class MyNolikesController extends BaseController
{
    @Autowired
    private IMyNolikesService myNolikesService;

    /**
     * 查询我的不喜欢列表
     */

    @GetMapping("/list")
    public TableDataInfo list(MyNolikes myNolikes)
    {
        startPage();
        List<MyNolikes> list = myNolikesService.selectMyNolikesList(myNolikes);
        return getDataTable(list);
    }

    /**
     * 导出我的不喜欢列表
     */

    @Log(title = "我的不喜欢", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MyNolikes myNolikes)
    {
        List<MyNolikes> list = myNolikesService.selectMyNolikesList(myNolikes);
        ExcelUtil<MyNolikes> util = new ExcelUtil<MyNolikes>(MyNolikes.class);
        util.exportExcel(response, list, "我的不喜欢数据");
    }

    /**
     * 获取我的不喜欢详细信息
     */

    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(myNolikesService.selectMyNolikesById(id));
    }

    /**
     * 新增我的不喜欢
     */

    @Log(title = "我的不喜欢", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody MyNolikes myNolikes)
    {
        return toAjax(myNolikesService.insertMyNolikes(myNolikes));
    }

    /**
     * 修改我的不喜欢
     */

    @Log(title = "我的不喜欢", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@RequestBody MyNolikes myNolikes)
    {
        return toAjax(myNolikesService.updateMyNolikes(myNolikes));
    }

    /**
     * 删除我的不喜欢
     */
    @Log(title = "我的不喜欢", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(myNolikesService.deleteMyNolikesByIds(ids));
    }
}
